import Vue from "vue";
import Router from "vue-router";

Vue.use(Router);

/* Layout */
import Layout from "../views/layout/Layout";

/**
 * hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
 *                                if not set alwaysShow, only more than one route under the children
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
 **/
export const constantRouterMap = [
  {
    path: "/login",
    component: () => import("@/views/login/index"),
    hidden: true,
  },
  {
    path: "/404",
    component: () => import("@/views/404"),
    hidden: true,
  },
  {
    path: "",
    component: Layout,
    redirect: "/home",
    meta: { title: "首页", icon: "home" },
    children: [
      {
        path: "home",
        name: "home",
        component: () => import("@/views/home/index"),
        meta: { title: "仪表盘", icon: "dashboard" },
      },
    ],
  },
];

export const asyncRouterMap = [
  {
    path: "/pms",
    component: Layout,
    redirect: "/pms/product",
    name: "pms",
    meta: { title: "产品管理", icon: "product" },
    children: [
      {
        path: "product",
        name: "product",
        component: () => import("@/views/pms/product/index"),
        meta: { title: "产品", icon: "product-list" },
      },
      {
        path: "addProduct",
        name: "addProduct",
        component: () => import("@/views/pms/product/add.vue"),
        meta: { title: "添加产品", icon: "product-list" },
        hidden: true,
      },
      {
        path: "productBindFile",
        name: "productBindFile",
        component: () => import("@/views/pms/product/bindFile.vue"),
        meta: { title: "编辑文件", icon: "product-list" },
        hidden: true,
      },
      {
        path: "updateProduct",
        name: "updateProduct",
        component: () => import("@/views/pms/product/update"),
        meta: { title: "修改产品", icon: "product-add" },
        hidden: true,
      },
      {
        path: "meta",
        name: "metaProduct",
        component: () => import("@/views/pms/meta/index"),
        meta: { title: "元产品" },
        hidden: true,
      },
      {
        path: "addMetaProduct",
        name: "addMetaProduct",
        component: () => import("@/views/pms/meta/addMeta"),
        meta: { title: "添加元产品" },
        hidden: true,
      },
      {
        path: "updateMetaProduct",
        name: "updateMetaProduct",
        component: () => import("@/views/pms/meta/update"),
        meta: { title: "编辑元产品" },
        hidden: true,
      },
      {
        path: "tag",
        name: "tag",
        component: () => import("@/views/pms/tag/index"),
        meta: { title: "标签" },
        hidden: true,
      },
      {
        path: "sku",
        name: "sku",
        component: () => import("@/views/pms/sku/index"),
        meta: { title: "产品规格" },
        hidden: true,
      },
      {
        path: "sku/add",
        name: "AddSku",
        component: () => import("@/views/pms/sku/add"),
        meta: { title: "添加产品规格" },
        hidden: true,
      },
      {
        path: "sku/update",
        name: "UpdateSku",
        component: () => import("@/views/pms/sku/update"),
        meta: { title: "编辑产品规格" },
        hidden: true,
      },
      {
        path: "sku/meta",
        name: "SkuMeta",
        component: () => import("@/views/pms/sku/meta"),
        meta: { title: "编辑元产品" },
        hidden: true,
      },
      {
        path: "sku/label",
        name: "SkuLabel",
        component: () => import("@/views/pms/sku/label"),
        meta: { title: "编辑Sku标签" },
        hidden: true,
      },
    ],
  },
  {
    path: "/oms",
    component: Layout,
    redirect: "/oms/order",
    name: "oms",
    meta: { title: "订单", icon: "order" },
    children: [
      {
        path: "order",
        name: "order",
        component: () => import("@/views/oms/order/index"),
        meta: { title: "订单列表", icon: "product-list" },
      },
      {
        path: "orderDetail",
        name: "orderDetail",
        component: () => import("@/views/oms/order/orderDetail"),
        meta: { title: "订单详情" },
        hidden: true,
      },
    ],
  },
  {
    path: "/dms",
    component: Layout,
    redirect: "/dms/member",
    name: "dms",
    meta: { title: "代理人管理", icon: "ums" },
    children: [
      {
        path: "member",
        name: "dmsMember",
        component: () => import("@/views/dms/member/index.vue"),
        meta: { title: "组织架构", icon: "ums-menu" },
      },
      {
        path: "addDmsMember",
        name: "addDmsMember",
        component: () => import("@/views/dms/member/add.vue"),
        meta: { title: "新增代理人", icon: "ums-menu" },
        hidden: true,
      },
      {
        path: "set-product",
        name: "setProduct",
        component: () => import("@/views/dms/set-product/index.vue"),
        meta: { title: "设置产品", icon: "ums-menu" },
      },
    ],
  },
  {
    path: "/ams",
    component: Layout,
    redirect: "/ams/list",
    name: "ams",
    meta: { title: "活动管理", icon: "activity" },
    children: [
      {
        path: "list",
        name: "amsList",
        component: () => import("@/views/ams/activity/index.vue"),
        meta: { title: "组织架构", icon: "ums-menu" },
      },
      {
        path: "coupon",
        name: "amsCoupon",
        component: () => import("@/views/ams/coupon/index.vue"),
        meta: { title: "优惠券列表", icon: "ums-menu" },
      },
      {
        path: "add-activity",
        name: "amsAddActivity",
        component: () => import("@/views/ams/activity/add.vue"),
        meta: { title: "优惠券列表", icon: "ums-menu" },
      },
    ],
  },
  {
    path: "/ums",
    component: Layout,
    redirect: "/ums/admin",
    name: "ums",
    meta: { title: "权限", icon: "ums" },
    children: [
      {
        path: "admin",
        name: "admin",
        component: () => import("@/views/ums/admin/index"),
        meta: { title: "用户列表", icon: "ums-admin" },
      },
      {
        path: "role",
        name: "role",
        component: () => import("@/views/ums/role/index"),
        meta: { title: "角色列表", icon: "ums-role" },
      },
      {
        path: "allocMenu",
        name: "allocMenu",
        component: () => import("@/views/ums/role/allocMenu"),
        meta: { title: "分配菜单" },
        hidden: true,
      },
      {
        path: "allocResource",
        name: "allocResource",
        component: () => import("@/views/ums/role/allocResource"),
        meta: { title: "分配资源" },
        hidden: true,
      },
      {
        path: "menu",
        name: "menu",
        component: () => import("@/views/ums/menu/index"),
        meta: { title: "菜单列表", icon: "ums-menu" },
      },
      {
        path: "addMenu",
        name: "addMenu",
        component: () => import("@/views/ums/menu/add"),
        meta: { title: "添加菜单" },
        hidden: true,
      },
      {
        path: "updateMenu",
        name: "updateMenu",
        component: () => import("@/views/ums/menu/update"),
        meta: { title: "修改菜单" },
        hidden: true,
      },
      {
        path: "resource",
        name: "resource",
        component: () => import("@/views/ums/resource/index"),
        meta: { title: "资源列表", icon: "ums-resource" },
      },
      {
        path: "resourceCategory",
        name: "resourceCategory",
        component: () => import("@/views/ums/resource/categoryList"),
        meta: { title: "资源分类" },
        hidden: true,
      },
    ],
  },
  {
    path: "/mms",
    component: Layout,
    redirect: "/mms/list",
    name: "mms",
    meta: { title: "订单", icon: "order" },
    children: [
      {
        path: "list",
        name: "mmsList",
        component: () => import("@/views/mms/list/index"),
        meta: { title: "用户管理", icon: "product-list" },
      },
    ],
  },
  {
    path: "/sms",
    component: Layout,
    redirect: "/sms/list",
    name: "sms",
    meta: { title: "供应商管理", icon: "order" },
    children: [
      {
        path: "rightOrder",
        name: "smsRightOrder",
        component: () => import("@/views/sms/rightOrder.vue"),
        meta: { title: "权益订单", icon: "product-list" },
      },
      {
        path: "rightOrderDetail",
        name: "smsRightOrderDetail",
        component: () => import("@/views/sms/rightOrderDetail.vue"),
        meta: { title: "权益订单详情", icon: "product-list" },
        hidden: true,
      },
    ],
  },
  { path: "*", redirect: "/404", hidden: true },
];

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap,
});
